@extends('admin/layout/master')
@section('title', '回复留言')
@section('title2', '回复留言')

@section('action')
    <a class="layui-btn layui-btn-small layui-btn-normal usersAdd_btn" href="{{ url('admin/comment/index/') }}"><i class="layui-icon"></i>留言列表</a>
    <!-- <a class="layui-btn layui-btn-small layui-btn-danger batchDel"><i class="layui-icon"></i>导出数据</a> -->
@endsection

@section('content')
    <div class="error">
        @if (count($errors) > 0)
            <div class="alert alert-danger">
                错误列表：
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif
    </div>

    <form class="layui-form" name="mainform" action="{{ url('/admin/comment/update',array('id'=>$olddata->id)) }}" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">所属文章</label>
            <div class="layui-input-block">
                <input type="text" value="{{ $article->title }}" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">昵称</label>
            <div class="layui-input-block">
                <input type="text" name="nickname" required  lay-verify="required" value="{{ $olddata->nickname }}" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
                <input type="text" name="email" required  lay-verify="required" value="{{ $olddata->email }}" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <textarea name="content" cols="80" rows="10">{{ $olddata->content }}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><b style="color: red;">回复</b></label>
            <div class="layui-input-block">
                <textarea name="reply" cols="80" rows="10">{{ $olddata->reply }}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                {{ csrf_field() }}
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
@endsection

@section('layuijs')
    <script>
        //一般直接写在一个js文件中
        layui.use(['layer', 'form', 'upload'], function(){
            var layer = layui.layer
                    ,form = layui.form;
            var upload = layui.upload;

            //执行实例
            var tag_token = $("[name='_token']").val();
            var uploadInst = upload.render({
                elem: '#test1' //绑定元素
                ,field: 'file_img'
                ,data: {'_token':tag_token}
                ,url: "{{url('/admin/tool/upload/file_img/')}}" //上传接口
                ,done: function(res){
                    //上传完毕回调
                    if(res.state == 1){
                        console.log(res);
                        layer.msg('上传成功');
                        $("#file_img").attr("src",res.re);
                        $("input[name='picname']").val(res.re);
                    } else {
                        layer.msg('上传失败');
                    }
                }
                ,error: function(){
                    //请求异常回调
                    layer.msg('上传失败');
                }
            });
        });

        // 设置value值
        $('.selected div').click(function(){
            var value = $(this).html();
            var value2 = $(this).attr('value');
            var tags = $("[name='tags']").val();
            if(tags.indexOf(value) == '-1'){
                if(tags){
                    $("[name='tags']").val(tags + "," + value);
                } else {
                    $("[name='tags']").val(value);
                }
            } else {
                if(tags){
                    tags = ','+tags+',';
                    tags = tags.replace(value+',', '');
                    tags = tags.substr(1);
                    tags = tags.substr(0,tags.length-1);
                    $("[name='tags']").val(tags);
                }
            }
        })
        // 关闭tags添加层
        $('.close').click(function(){
            $("#tags_mian").css('display','none');
        });
        // 打开tages层
        $("[name='tags']").click(function(){
            console.log(11);
            $("#tags_mian").css('display','flex');
        });
    </script>
    <!-- 配置文件 -->
    <script type="text/javascript" src="{{ asset('/plus/ueditor/ueditor.config.js') }}"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="{{ asset('/plus/ueditor/ueditor.all.min.js') }}"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('body',{initialFrameHeight: "500"});
    </script>
@endsection